package Sort;
public class Sort {

	public static <X> Comparable<X>[] QuickSort(Comparable<X>[] array, int a, int b) {
		int left=a, right=b;
		X m=(X)array[(a+b)/2];
	      while(left<right)
	      {
	          while(array[left].compareTo(m)<0) left++;
	          while(array[right].compareTo(m)>0) right--;
	          if(left<=right)
	          {           
	              X temp = (X)array[left];
	              array[left] = array[right];
	              array[right] = (Comparable<X>) temp;
	              left++;
	              right--;
	          }
	      }
	      if(right > a) array=QuickSort(array, a, right);
	      if(left < b) array=QuickSort(array, left, b);
		return array;
	}
}


